<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/Home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-table
        ref="filterTable"
        :data="tableData"
        style="width: 100%"
        border
        stripe
        height="550"
        >
        <el-table-column fixed type="index" label="#" align="center"></el-table-column>
        <el-table-column
          prop="authName"
          label="权限列表"
          column-key="authName"
        >
        </el-table-column>
        <el-table-column
          prop="path"
          label="路径"
        >
        </el-table-column>
        <el-table-column
          prop="level"
          label="权限等级"
          width="300"
          align="center"
          :filters="[{ text: '一级', value: '0' }, { text: '二级', value: '1' }
          , { text: '三级', value: '2' }]"
          :filter-method="filterTag"
          filter-placement="bottom-end">
          <template slot-scope="scope">
            <!--<el-tag
              :type="scope.row.level === '0' ? 'primary' : scope.row.level==='1'?'success':'warning'"
              disable-transitions>{{scope.row.level==='0'?'一级':scope.row.level==='1'?'二级':'三级'}}</el-tag>-->
            <el-tag type="primary" v-if="scope.row.level==='0'">一级</el-tag>
            <el-tag type="success" v-else-if="scope.row.level==='1'">二级</el-tag>
            <el-tag type="warning" v-else>三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>

  </div>

</template>
<script>
export default {
  created () {
    this.getRights()
  },
  data () {
    return {
      tableData: []
    }
  },
  methods: {
    filterTag (value, row) {
      return row.level === value
    },
    async getRights () {
      const { data: res } = await this.$http.get('rights/list')
      if (res.meta.status !== '200') {
        this.tableData = res.data
      } else {
        this.$message.error(res.meta.msg)
      }
    }
  }
}
</script>
<style lang="less" scoped>
</style>
